<include file="../header" />
<body class="J_scroll_fixed">
        <script type="text/javascript">
            $(function() {

				$("select[name='activityType']").change(function () {

					if($("select[name='activityType']").val() == 1) {
						$(".other-info").hide();
                        $(".own-info").show();
					} else if ($("select[name='activityType']").val() == 3){
						$(".own-info").hide();
						$(".other-info").hide();
                        $(".news-info").show();
					}else{
                        $(".own-info").hide();
                        $(".other-info").show();
                    }

				});

                $("select[name='activityPay']").change(function () {

                    if($("select[name='activityPay']").val() == 1) {
                        $(".price-info").show();
                    } else {
                        $(".price-info").hide();
                    }

                });

                var description = UE.getEditor('description',{
                    initialFrameHeight:300,
                    initialContent : "",
                    serverUrl :'{:U("activity/ueditorUpload")}'
                });
                
                $("button#upload").click(function(){     
                     //上传文件
                   $.ajaxFileUpload({
                       url:"{:U('activity/uploadImage')}",//处理图片脚本
                       secureuri :false,
                       fileElementId :'fileToUpload',//file控件id
                       dataType : 'json',
                       success : function (data, status){
						   $("input[name=titleImage]").val(data);
						   $("img[name=preShow]").attr("src", data);
                       },
                       error: function(data, status, e){
                           alert(e);
                       }
                   })
               });
               
               $("button.btn_submit").click(function() {

                   $("input[name=description]").val(description.getContent());
                   
                   $("form").submit();
                   
               })
               
            })
            
        </script>
        <script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.config.js"></script>
        <script type="text/javascript"  src="__TMP__/assets/js/ueditor/ueditor.all.min.js"></script>
	<div class="wrap jj">
		<div class="common-form">
			<form method="post" class="form-horizontal J_ajaxForm" action="{:U('activity/addPost')}">
				<fieldset>
					<div class="control-group">
						<label class="control-label">标题：</label>
						<div class="controls">
							<input type="text" class="input" name="title" value="">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">标题图片:</label>
						<div class="controls">
							<input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
							<button type="button" class="btn btn-primary" id="upload">上传</button>
							<input type="hidden" name="titleImage" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">图片预览:</label>
						<div class="controls">
							<img src="" name="preShow" style="width:400px;height:200px;" />
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">活动类型：</label>
						<div class="controls">
							{:getEnumSelectWidget($activityTypeEnum, 'activityType', 0, 0)}
						</div>
					</div>
					<div class="control-group other-info own-info">
						<label class="control-label">联系方式：</label>
						<div class="controls">
							<input type="text" class="input" name="contact" value="">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">所属病症：</label>
						<div class="controls">
							<select name="categoryId">
								{:getCategorySelectOptionHtml(0, 0)}
							</select>
						</div>
					</div>
					<div class="control-group other-info" style="display: none;">
						<label class="control-label">跳转链接：</label>
						<div class="controls">
							<input type="text" class="input" name="activityLink" value="">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">开始时间：</label>
						<div class="controls">
							<input type="text" class="input J_datetime" name="beginTime" value="">
						</div>
					</div>
					<div class="control-group">
						<label class="control-label">结束时间：</label>
						<div class="controls">
							<input type="text" class="input J_datetime" name="endTime" value="">
						</div>
					</div>
					<div class="control-group other-info own-info">
						<label class="control-label">活动地点：</label>
						<div class="controls">
							<input type="text" class="input" name="location" value="">
						</div>
					</div>
					<div class="control-group other-info own-info">
						<label class="control-label">是否付费：</label>
						<div class="controls">
							{:getEnumSelectWidget($activityPayEnum, 'activityPay', 0, 0)}
						</div>
					</div>
					<div class="control-group price-info" style="display: none;">
						<label class="control-label">价格：</label>
						<div class="controls">
							<input type="text" class="input" name="price" value="">
						</div>
					</div>
					<div class="control-group other-info own-info">
						<label class="control-label">人数上限：</label>
						<div class="controls">
							<input type="text" class="input" name="upperLimit" value="">
						</div>
					</div>

					<div class="own-info news-info">
						<div class="control-group">
							<label class="control-label">详情描述：</label>
							<div class="controls">
								<input type="hidden" name="description" />
								<script type="text/plain" id="description" name="description"></script>
							</div>
						</div>
					</div>
                                    
				</fieldset>
				<div class="form-actions">
					<button type="button" class="btn btn-primary btn_submit">添加</button>
					<a class="btn" href="__URL__">返回</a>
				</div>
			</form>
		</div>
	</div>
	<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>